package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.QuartzBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.service.JobUtil;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class JobResume implements ServerInterface{

	
	private Logger log = LogManager.getLogger(JobResume.class);
	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		MessageBean<?> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success",void.class); ;
		try {
			QuartzBean bean = JsonUtils.objectToPojo(req.getData(),QuartzBean.class);
			info = JobUtil.resumeJob(bean.getJobName(),bean.getJobGroup());
			return info;
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			log.error("恢复任务失败",e);
			return info;
		}	
	}

}
